﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using BierdopjeTV.API;


namespace BierdopjeTV.Configuration
{
    public partial class frmZoekShow : Form
    {
        public int ShowID;

        public frmZoekShow(string ShowName)
        {
            InitializeComponent();
            this.Text = this.Text + " - " + ShowName;
            txtZoekOpdracht.Text = ShowName;
            
        }

        private void btnZoeken_Click(object sender, EventArgs e)
        {
            ZoekShows();
        }

        private void frmZoekShow_Load(object sender, EventArgs e)
        {
            ZoekShows();
        }

        private void datagridShowsFound_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            ShowID = Convert.ToInt32(datagridShowsFound.Rows[e.RowIndex].Cells[0].Value);
            this.Dispose();
        }

        private void ZoekShows()
        {
            APIFunctions API = new APIFunctions();
            List<BierdopjeShows> ShowsFound = API.FindShowByName(txtZoekOpdracht.Text);

            datagridShowsFound.Rows.Clear();

            foreach (BierdopjeShows _BierdopjeShow in ShowsFound)
            {
                datagridShowsFound.Rows.Add(_BierdopjeShow.ShowID.ToString(), _BierdopjeShow.ShowName);
            }
        }



    }
}
